<template>
  <c-form-dialog
    ref="form"
    title="项目受理"
    :visible.sync="innerVisible"
    :form-items="formItems"
    :form-data="formData"
    :table-name="tableName"
    :table-id="tableId"
    @close="handleClose"
    @success="handleSuccess"
    :before-save="handleBeforeSave"
  ></c-form-dialog>
</template>

<script>
import SelectStaff from '@/components/select/SelectStaff'
export default {
  components: {},
  props: {
    visible: Boolean,
    tableId: String,
    formData: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      tableName: 'customer_related',
      innerVisible: false,
      formItems: [
        {
          tag: SelectStaff,
          itemAttrs: {
            label: '项目A角',
            rules: [{ required: true, message: '请选择项目A角', trigger: 'change' }],
          },
          attrs: {
            key: 'city_res_a',
            value: '',
            placeholder: '请选择项目A角',
            class: 'form-control-ml',
          },
          events: {
            select: (model, staff) => {
              model.city_res_a_name = staff.realName
              model.city_res_a_phone = staff.phoneNumber
            },
          },
        },
        {
          tag: 'input',
          attrs: { key: 'city_res_a_phone', value: '' },
          ifShow: false,
        },
        {
          tag: 'input',
          attrs: { key: 'city_res_a_name', value: '' },
          ifShow: false,
        },
        {
          tag: SelectStaff,
          itemAttrs: {
            label: '项目B角',
            rules: [{ required: true, message: '请选择项目B角', trigger: 'change' }],
          },
          attrs: {
            key: 'city_res_b',
            value: '',
            placeholder: '请选择项目B角',
            class: 'form-control-ml',
          },
          events: {
            select: (model, staff) => {
              model.city_res_b_name = staff.realName
              model.city_res_b_phone = staff.phoneNumber
            },
          },
        },
        {
          tag: 'input',
          attrs: { key: 'city_res_b_phone', value: '' },
          ifShow: false,
        },
        {
          tag: 'input',
          attrs: { key: 'city_res_b_name', value: '' },
          ifShow: false,
        },
        {
          tag: SelectStaff,
          itemAttrs: {
            label: '风控员',
            rules: [{ required: true, message: '请选择风控员', trigger: 'change' }],
          },
          attrs: {
            key: 'city_res_person_risk_point',
            value: '',
            includeJob: ['org_r_emp', 'org_r_manage', 'org_dg_risk_manage'],
            placeholder: '请选择风控员',
            class: 'form-control-ml',
          },
          events: {
            select: (model, staff) => {
              model.city_res_person = staff.realName
            },
          },
        },
        {
          tag: 'input',
          attrs: { key: 'city_res_person', value: '' },
          ifShow: false,
        },
      ],
    }
  },
  computed: {},
  watch: {
    visible(val) {
      this.innerVisible = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleBeforeSave(model) {
      model.is_approval_gua = 1
      return model
    },
    handleClose() {
      this.$emit('update:visible', false)
    },
    handleSuccess(res) {
      this.$emit('success', res)
    },
  },
}
</script>

<style lang="scss" scoped></style>
